<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<meta http-equiv="description" content="" />
		<meta http-equiv="cache-control" content="no-cache"/>
		<meta http-equiv="pragma" content="no-cache"/>
		<meta http-equiv="Expires" content="0"/>
		
		<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath() %>'/>
		<link href="/css/ddaccordion.css" rel="stylesheet" type="text/css" media="screen" />
		<link href="/css/jquery-ui-1.7.2.custom.css" rel="stylesheet" type="text/css" media="screen" />
		<link href="/css/yaodian100midend.css" rel="stylesheet" type="text/css" media="screen" />
		<link href="/css/pageable.css" type="text/css" rel="stylesheet" media="screen" />
		
		<script src="/js/jquery-1.3.2.min.js" type="text/javascript" charset="UTF-8"></script>
		<script src="/js/jquery-ui-1.7.2.custom.min.js" type="text/javascript" charset="UTF-8"></script>
		<script src="/js/pageable.js" type="text/javascript" charset="UTF-8"></script>
		<script src="/js/ddaccordion.js" type="text/javascript" charset="UTF-8"></script>
		<script src="/js/ddaccordion-cfg.js" type="text/javascript" charset="UTF-8"></script>
		<script>
		$().ready(function() {
			var flip = 0;
			$('#doMemo').click(function() {
				var boo = flip++ % 2 == 0;
				memoBtnSwitch(boo);
			});
			
			$('#clBtn').click(function() {
				var boo = flip++ % 2 == 0;
				memoBtnSwitch(boo);
			});
			
			$('#sbBtn').click(function() {
				var isCorrect = true;
				if( $('#orderMemo_memo').val().length == 0 ) {
					alert('请输入订单信息');
					$('#orderMemo_memo').focus();
					isCorrect = false;
				} else if( $('#orderMemo_memo').val().length > 300 ) {
					alert('你输入的内容字数：'+$('#orderMemo_memo').val().length+'，已超过300字限制。');
					$('#orderMemo_memo').focus();
					isCorrect = false;
				}
				if( isCorrect ) {
					$('#memoForm').submit();
					var boo = flip++ % 2 == 0;
					memoBtnSwitch(boo);
				}
			});
		});
		
		function memoBtnSwitch(boo) {
			$('#editMemo').toggle( boo );
			if(boo) {
				$('#doMemo').val('取消');
			} else {
				$('#doMemo').val('留言');
				$('#orderMemo_memo').val('');
			}
		}
		</script>
	</head>
	<body>
		<!-- <h1>订单信息</h1> -->
		<font color="#ff3300">
		<s:actionerror />
		<s:actionmessage />
		${errMsg }
		<s:fielderror />
		</font>
		<div style="overflow: hidden; width: 100%;">
			<div style="float: left;font-size: 12px;font-weight: normal;margin: 15px 0 10px;">订单编号：${orderId}</div>
			<div style="float: right;font-size: 12px;font-weight: normal;margin: 15px 0 10px;"><input id="doMemo" type="button" value="留言" /></div>
		</div>
		<div id="editMemo" style="display: none;">
			<s:form action="saveOrderMemo.do" namespace="/order" method="post" id="memoForm" name="memoForm">
				<table width="100%">
					<tr>
						<td>
							<input type="hidden" name="orderMemo.orderId" value="${orderId}" />
							<textarea id="orderMemo_memo" name="orderMemo.memo" rows="3" style="float: left; width: 100%;"></textarea>
						</td>
					</tr>
					<tr>
						<td>
							<div class="txt-rd" style="float: left; font-size: 12px; margin: 15px 0 10px;">字数不可超过300个字</div>
							<div style="float: right;font-size: 12px;font-weight: normal;margin: 15px 0 10px;">
								<input id="clBtn" type="button" value="取消" />
								<input id="sbBtn" type="button" value="储存" />
							</div>
						</td>
					</tr>
				</table>
			</s:form>
		</div>
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tb-1">
			<thead>
				<tr>
					<th>信息内容</th>
					<th width="150">建立者</th>
					<th width="150">建立日期</th>
				</tr>
			</thead>
			<tbody>
				<s:if test="%{orderMemos.size > 0}">
					<s:iterator value="orderMemos" var="m" status="idx">
						<s:set name="i" value="%{#idx.index}" />
						<s:set name="no" value="%{#i + 1}" />
				<tr class="${no%2==0 ? 'bg-yl' : ''}">
					<td style="text-align:left; font-size: 12px;">${m.memo}</td>
					<td style="font-size: 12px;">${m.createUser}</td>
					<td style="font-size: 12px;"><fmt:formatDate value="${m.createDate}" pattern="yyyy-MM-dd HH:mm" /></td>
				</tr>
					</s:iterator>
				</s:if>
				<s:else>
				<tr class="bg-yl"><td colspan="3" style="font-size: 12px;">无资料!!</td></tr>
				</s:else>
			</tbody>
		</table>
		<yaodian100:pageutil link="viewOrderMemo.do" pagerObj="${pager}" />
	</body>
</html>